/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.srcptit.trainning.giangnd.btvn2;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


/**
 *
 * @author GIANG
 */
public class B1 {

    /**
     * @param n
     * @param m
     * @throws java.io.IOException
     */
    public static void doiCoSo(int n,int m) throws IOException{ 
        BufferedWriter bf;
        int du=n%m;
        bf = new BufferedWriter(new FileWriter("Data/B1OUT.txt"));
        if(n>=m) doiCoSo(n / m,m); 
        if(du>9) {
            System.out.printf("%c",du+55); 
            bf.write(du+55);
        }
        else {
            System.out.print((du)); 
            bf.write(du);
            }
        bf.close();
    } 
    public static void main(String[] args) throws IOException {
        String n = null,m = null;
        int a=0,b=0;
        BufferedReader br=new BufferedReader(new FileReader("Data/B1.txt"));
        while(br.ready() == true){
            n=br.readLine();
            m=br.readLine();
            a=Integer.parseInt(n);
            b=Integer.parseInt(m);
        }
        System.out.println("a="+a+" b="+b);
        System.out.println(a+"trong he co so"+b+"la:");
        doiCoSo(a,b);
    }
}
